//
//  IconPickerViewController.swift
//  Todo-Lists
//
//  Created by stu on 2019/10/22.
//  Copyright © 2019年 stu. All rights reserved.
//

import UIKit
protocol IconPickerViewControllerDelegate: class {
    func iconPicker(_picker: IconPickerViewController,didPick iconName: String)
}

class IconPickerViewController: UITableViewController {
    weak var delegate: IconPickerViewControllerDelegate?
    
    let icons = ["No Icon","Appointments","Birthdays","Chores","Drinks","Folder","Groceries","Inbox","Photos","Trips",]
    let iconNames = ["不显示图标","预约","生日","家务","酒宴","文件","杂货","收件箱","照片","出行",]
    override func viewDidLoad() {
        super.viewDidLoad()

      
    }
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return icons.count
    }
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "IconCell", for: indexPath)
        cell.textLabel!.text = iconNames[indexPath.row]
        cell.imageView!.image = UIImage(named: icons[indexPath.row])
        
        return cell
    }
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if let delegate = delegate{
            let iconName = icons[indexPath.row]
            delegate.iconPicker(_picker: self, didPick: iconName)
        }
    }
    
}
